<?php

//Use: point browser to this file ej:localhost/data/setupdb.php

//CONNECT
$con = mysql_connect("localhost","bob","");
if(!$con)die('Could not connect: ' . mysql_error());
else echo "Connection OK<br>";

//CREATE MAIN DB
if (mysql_query("CREATE DATABASE city",$con))echo "Database created<br>";
else echo "Error creating database: " . mysql_error();

//CREATE TABLES
mysql_select_db("city",$con);

//classifications
$sql = "CREATE TABLE classifications(classification varchar(60))";
$result=mysql_query($sql,$con);
$sql = "load data local infile 'classifications_ES.txt' into table classifications";
$result=mysql_query($sql,$con);

//published_articles
$sql = "CREATE TABLE published_articles(
 id int NOT NULL AUTO_INCREMENT,
 PRIMARY KEY(id),
 pwd varchar(10),
 name varchar(30),
 classification varchar(30),
 subclassification varchar(30),
 street varchar(30),
 number varchar(10),
 postalcode varchar(10),
 lat varchar(50),
 lng varchar(50),
 tel varchar(20),
 page varchar(20),
 mail varchar(30))";
$result=mysql_query($sql,$con);

//Close
mysql_close($con);

?> 
